#ifndef USERSCHEDULEDATA_H
#define USERSCHEDULEDATA_H

#include <QString>
#include <QStringList>
#include <QChar>
#include <QDate>
#include <QMap>

typedef enum {
    DAYOFF, DAILY, NIGHTLY, UNAVAILABLE
} ShiftType;

/* ************************************************************************************ */

class UserScheduleData {
public:
    static const QChar DEFAULT_SEPARATOR;

    UserScheduleData(int shiftsNumber = 0);

    virtual ~UserScheduleData();

    void setShiftType(int day, ShiftType type);

    ShiftType getShiftType(int day);

    void switchShiftType(int day);

    void fromString(const QString& serialized, const QChar separator = DEFAULT_SEPARATOR);

    QString toString(const QChar& separator = DEFAULT_SEPARATOR) const;

private:
    QList<ShiftType> shifts_;
};

/* ************************************************************************************ */

class Schedule {
public:
    Schedule(const QDate& date = QDate::currentDate());
    virtual ~Schedule();

    static Schedule loadFromFile(const QString& path);
    static Schedule loadFromFile(const QDate& date);

    QString hash() const;
    static QString hash(int month, int year);

    void addUser(const QString& name);
    QString getUser(int i) const;
    ShiftType getShiftType(int user, int day);
    void switchShiftType(int user, int day);

    QString getLabel(int day);

    int getUsersNumber() const;
    int getShiftsNumber() const;

    bool userExists(const QString& user) const;

private:
    int month_;
    int year_;
    int shiftsNumber_;
    QString hash_;

    QMap<QString, UserScheduleData> entries_;
};

#endif // USERSCHEDULEDATA_H
